package com.itqf.controller;

import com.itqf.annotation.RequiresPermissionsDesc;
import com.itqf.bean.DtsStorage;
import com.itqf.dto.CommonsDto;
import com.itqf.service.DtsStorageService;
import com.itqf.util.ResponseUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * projectName: gp_manage
 *
 * @author: 赵伟风
 * time: 2021/8/23 14:27
 * description:
 */

@RestController
@CrossOrigin("*")
@RequestMapping("admin/storage/")
public class AdminDtsStorageController {

    @Autowired
    private DtsStorageService dtsStorageService;

    /**
     * 查询存储对象接口
     * @return
     */
    @RequiresPermissions("admin:storage:list")
    @RequiresPermissionsDesc(menu = {"系统管理","存储对象"},button="查看")
    @GetMapping("list")
    public Object list(CommonsDto commonsDto){

        Object data =  dtsStorageService.findStorageByPage(commonsDto);

        return ResponseUtil.ok(data);
    }


    @RequiresPermissions("admin:storage:create")
    @RequiresPermissionsDesc(menu = {"系统管理","对象存储"},button = "创建")
    @PostMapping("create")
    public Object create(MultipartFile file) throws Exception {

        DtsStorage dtsStorage = dtsStorageService.insertStorage(file);

        return ResponseUtil.ok(dtsStorage);
    }

}
